package com.gaohe.web.controller.hotal;

import com.gaohe.common.annotation.Log;
import com.gaohe.common.core.controller.BaseController;
import com.gaohe.common.core.domain.AjaxResult;
import com.gaohe.common.core.page.TableDataInfo;
import com.gaohe.common.enums.BusinessType;
import com.gaohe.common.utils.poi.ExcelUtil;
import com.gaohe.hotal.domain.HotHotal;
import com.gaohe.hotal.service.IHotHotalService;
import com.gaohe.hotal.vo.HotHotalVo;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 门店管理Controller
 *
 * @author zl
 * @date 2025-06-26
 */
@RestController
@RequestMapping("/hotal/hotal")
public class HotHotalController extends BaseController
{
    @Autowired
    private IHotHotalService hotHotalService;

    /**
     * 查询门店管理列表
     */
    @PreAuthorize("@ss.hasPermi('hotal:hotal:list')")
    @GetMapping("/list")
    public TableDataInfo list(HotHotal hotHotal)
    {
        startPage();
        List<HotHotal> list = hotHotalService.selectHotHotalList(hotHotal);
        return getDataTable(list);
    }

    /**
     * 导出门店管理列表
     */
    @PreAuthorize("@ss.hasPermi('hotal:hotal:export')")
    @Log(title = "门店管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HotHotal hotHotal)
    {
        List<HotHotal> list = hotHotalService.selectHotHotalList(hotHotal);
        ExcelUtil<HotHotal> util = new ExcelUtil<HotHotal>(HotHotal.class);
        util.exportExcel(response, list, "门店管理数据");
    }

    /**
     * 获取门店管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('hotal:hotal:query')")
    @GetMapping(value = "/{hotalId}")
    public AjaxResult getInfo(@PathVariable("hotalId") Long hotalId)
    {
        return success(hotHotalService.selectHotHotalByhotalId(hotalId));
    }

    /**
     * 新增门店管理
     */
    @PreAuthorize("@ss.hasPermi('hotal:hotal:add')")
    @Log(title = "门店管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HotHotal hotHotal)
    {
        return toAjax(hotHotalService.insertHotHotal(hotHotal));
    }

    /**
     * 修改门店管理
     */
    @PreAuthorize("@ss.hasPermi('hotal:hotal:edit')")
    @Log(title = "门店管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HotHotal hotHotal)
    {
        return toAjax(hotHotalService.updateHotHotal(hotHotal));
    }

    /**
     * 删除门店管理
     */
    @PreAuthorize("@ss.hasPermi('hotal:hotal:remove')")
    @Log(title = "门店管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{hotalIds}")
    public AjaxResult remove(@PathVariable Long[] hotalIds)
    {
        return toAjax(hotHotalService.deleteHotHotalByhotalIds(hotalIds));
    }
//    ---------------------------------------------------------------------------
    /**
     * 查询门店管理列表
     */
    @PreAuthorize("@ss.hasPermi('hotal:hotal:list')")
    @GetMapping("/listhotal")
    public TableDataInfo listhotal(HotHotal hotHotal)
    {
        startPage();
        List<HotHotalVo> listVo = hotHotalService.selectHotHotalVoList(hotHotal);
        return getDataTable(listVo);
    }


    /**
     * 获取门店管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('hotal:hotal:query')")
    @GetMapping(value = "/gethotalById/{hotalId}")
    public AjaxResult gethotalById(@PathVariable("hotalId") Long hotalId)
    {
        HotHotalVo hotal = hotHotalService.gethotalById(hotalId);
        return success(hotal);
    }

    /**
     * 新增门店管理   未完成
     */
    @PreAuthorize("@ss.hasPermi('hotal:hotal:add')")
    @Log(title = "门店管理", businessType = BusinessType.INSERT)
    @PostMapping("/addhotal")
    public AjaxResult addhotal(@RequestBody HotHotal hotHotal)
    {
        return toAjax(hotHotalService.insertHotHotal(hotHotal));
    }

    /**
     * 修改门店管理   未完成
     */
    @PreAuthorize("@ss.hasPermi('hotal:hotal:edit')")
    @Log(title = "门店管理", businessType = BusinessType.UPDATE)
    @PutMapping("/updatehotal")
    public AjaxResult updatehotal(@RequestBody HotHotal hotHotal)
    {
        return toAjax(hotHotalService.updateHotHotal(hotHotal));
    }

}
